package com.weifangfirecontrolformal.weifangfirecontrolformal.web.web.noticeannouncement;

import cn.hutool.json.JSONObject;
import com.weifangfirecontrolformal.weifangfirecontrolformal.common.base.BaseController;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.Action;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.At;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.model.RespEntity;
import com.weifangfirecontrolformal.weifangfirecontrolformal.web.service.noticeannouncement.NoticeannouncementService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * 通知公告控制器
 */
@Action
@RequestMapping(value="noticeAnnouncement/noticeAnnouncement")
public class NoticeannouncementController extends BaseController {
    @Resource
    public NoticeannouncementService noticeannouncementService;

    /**
     * 通知公告的列表查询
     * @param
     * //page    第几页
     * limit	每页多少条
     * announcementType	通告类型的id：对应字典表中的数据
     * state	通告状态:0 暂存草稿  1 直接发布
     * starttime	开始时间
     * endtime	结束时间
     * @return
     */
    @At(value = "listNoticeAnnouncementListPage", method = RequestMethod.GET, param = { "page","limit" })
    public RespEntity listNoticeAnnouncementListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.listNoticeAnnouncementListPage(jsonParam);
    }

    /**
     * 通知公告的新增或修改
     * @param
     * //announcementType    通告类型的id：对应字典表中的数据
     * contentDes	内容描述
     * state	通告状态:0 暂存草稿  1 直接发布
     * ishaveReceivingUnit	是否有接收单位：0 没有 1 有
     * ishaveFile	是否有附件：0 没有 1 有
     * fileName	附件名称
     * filePath	附件路径
     * bottomArea	当allflag为1时，它有值，此时units无值；当allflag为0时，它无值，此时units可能有值
     * allflag	选择下属所有企业 1 是  0 否
     * id	通知公告的id
     * units	接收单位信息：为一个逗号分隔的字符串，分隔的单位id；
     * @return
     */
    @At(value = "addOrUpdate", method = RequestMethod.POST, param = { "announcementType","state","ishaveReceivingUnit","ishaveFile" })
    public RespEntity addOrUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.addOrUpdate(jsonParam);
    }

    /**
     * 通知公告的删除
     * @param
     * //id    通告公告的id
     * @return
     */
    @At(value = "delete", method = RequestMethod.POST, param = { "id" })
    public RespEntity delete(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.delete(jsonParam);
    }

    /**
     * 通知公告详情
     * @param
     * //id    通知公告的id
     * @return
     */
    @At(value = "getById", method = RequestMethod.GET, param = { "id"})
    public RespEntity getById(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.getById(jsonParam);
    }

    /**
     * 字典组查询
     * @param  //groupname	字典组
     * @return
     */
    @At(value = "dictList", method = RequestMethod.GET, param = { "groupname" })
    public RespEntity dictList(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.dictList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 工作管理信息统计
     * @Date Created in 14:07 2024/5/11
     * @Param [jsonParam]
     */

    @At(value = "workCount", method = RequestMethod.GET)
    public RespEntity workCount(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.workCount(jsonParam);
    }

    /**
     * 安全知识分页列表
     * @param
     * @return
     */
    @At(value = "getSafetyKnowledgeListPage", method = RequestMethod.GET, param = { "page","limit","knowledgeType" })
    public RespEntity getSafetyKnowledgeListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.getSafetyKnowledgeListPage(jsonParam);
    }
    /**
     * 文章新增或编辑
     * @param
     * @return
     */
    @At(value = "addOrUpdateArticle", method = RequestMethod.POST, param = { "title","introduction","knowledgeTypeId" })
    public RespEntity addOrUpdateArticle(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.addOrUpdateArticle(jsonParam);
    }

    /**
     * 文章删除
     * @param
     * @return
     */
    @At(value = "delArticle", method = RequestMethod.POST, param = { "id" })
    public RespEntity delArticle(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.delArticle(jsonParam);
    }

    /**
     * 文章操作
     * @param
     * @return
     */
    @At(value = "articleOperation", method = RequestMethod.POST, param = { "id","state" })
    public RespEntity articleOperation(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.articleOperation(jsonParam);
    }

    /**
     * 安全知识评论分页列表
     * @param
     * @return
     */
    @At(value = "getCommentListPage", method = RequestMethod.GET, param = { "page","limit","knowledgeId" })
    public RespEntity getCommentListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.getCommentListPage(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 新增评论
     * @Date Created in 15:23 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "addComment", method = RequestMethod.POST, param = { "knowledgeId","content","userName" })
    public RespEntity addComment(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.addComment(jsonParam);
    }
    /**
     * @Author YangYu
     * @Description 删除评论
     * @Date Created in 15:23 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "delComment", method = RequestMethod.POST, param = { "id" })
    public RespEntity delComment(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.delComment(jsonParam);
    }
    /**
     * 图文类型不分页列表
     * @param
     * @return
     */
    @At(value = "textTypeList", method = RequestMethod.GET)
    public RespEntity textTypeList(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.textTypeList(jsonParam);
    }
    /**
     * 图文类型详情
     * @param
     * @return
     */
    @At(value = "detailsTextType", method = RequestMethod.GET, param = { "id" })
    public RespEntity detailsTextType(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.detailsTextType(jsonParam);
    }
    /**
     * 图文类型新增、更新
     * @param
     * @return
     */
    @At(value = "addOrUpdateTextType", method = RequestMethod.POST)
    public RespEntity addOrUpdateTextType(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.addOrUpdateTextType(jsonParam);
    }
    /**
     * 删除图文类型
     * @param
     * @return
     */
    @At(value = "delTextType", method = RequestMethod.POST)
    public RespEntity delTextType(@RequestBody(required = false) JSONObject jsonParam) {
        return noticeannouncementService.delTextType(jsonParam);
    }
}
